<?php
include_once('/ezSql/shared/ez_sql_core.php');
include_once('/ezSql/mysql/ez_sql_mysql.php');

$db = new ezSQL_mysql('adriano','adriano','tmp','localhost');


$users = $db->get_results("SELECT field1, field2 FROM tmp");



foreach ( $users as $user )
{
	// Access data using object syntax
	echo $user->field1;
	echo '<br>';
	echo $user->field2;
	echo '<br>';
}


// simple query
$var = $db->get_var("select count(*) from tmp");
echo $var;
echo '<br>';
// Display last query and all associated results
$db->debug();

// insert data
//$db->query("INSERT INTO tmp (idtmp, field1, field2, field3) VALUES (3,'justin','jv@foo.com', 'lastitem')");





// Display the structure and contents of any result(s) .. or any variable
$results = $db->get_results("SELECT field1, field2 FROM tmp");
$db->vardump($results);



// Get 'one column' (based on COLUMN index) and print it out..
$names = $db->get_col("SELECT field1,field2 FROM tmp",0);
foreach ( $names as $name )
{
	echo $name;
}
echo '<br>';


$current_time = $db->get_var("SELECT " . $db->sysdate());
print "ezSQL demo for mySQL database run @ $current_time";

echo '<br><br>';

// Get list of tables from current database..
$my_tables = $db->get_results("SHOW TABLES",ARRAY_N);

// Print out last query and results..
$db->debug();




// test new connection
$newConn = new ezSQL_mysql('adriano','adriano','frogcms','localhost');
$my_tables = $newConn->get_results("SHOW TABLES",ARRAY_N);
$db->debug();






?>